<?php
include '../../../common.inc.php';
include 'fun.php';
$mysqli = new mysqli('localhost', 'root', '', 'test_data');
$sql = "select id, py_lower, dianming, chengshi
		from koubei_myisam2
		where length(py_lower) >20 and dianming REGEXP '.*[_].*'
		order by id desc
		limit 100";
$result = $mysqli->query($sql);
$res = $result->fetch_all(MYSQLI_ASSOC);
if (!$res) exit('No More Results');
foreach ($res as $r) {
	$dianming = str_replace(
		array(' ', '&amp;'  , '·', '&middot;', '&', '。'   , '、' , '【' , '】', '（', '）', '！', 'Ⅱ','Ｓ', '―', '，', '：', '★', '《','》', '◥','◣', '◢','◤'),
		array('_', '_'      , '_', '_'       , '_', ''     , ''   , ''  , ''  , '_' ,'_'  , '_', '2','s', '_', '_' , '_' , ''  , ''  , '', '', '', ''  , ''),
		$r['dianming']
	);
	$dianming = preg_replace("/(_.*)/is", '', $dianming);
	$py = str2py($dianming .'_'. $r['chengshi']);

	$sql = "update koubei_myisam2 set py_lower ='{$py}' WHERE ID = {$r['id']}";
	$mysqli->query($sql);
}
echo '<meta http-equiv="refresh" content="1; url='.$_SERVER['PHP_SELF'].'" />';
echo '<pre style="font-size:300px;">';
echo $r['id'];

?>